#!/data/Software/mydan/perl/bin/perl -I/data/Software/mydan/CI/lib -I/data/Software/mydan/CI/private/lib
use strict;
use warnings;
use MYDB;
use POSIX;
use FindBin qw( $RealBin );
use Data::Dumper;
use Code;

use MYDan::Util::OptConf;

=head1 SYNOPSIS

 $0 [--flowlineid id] [--version release-01] --todate 2020-02-02
   --probabilityhour '0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,4,5,6,30,8,0,0,0' # probability, ...
   --probabilityweek '0:0,2:10,3:10,0:0,0:0,0:0,0:0' # runcount:probability, ...

   --deployuuid uuid
   --testuuid uuid

=cut
my $option = MYDan::Util::OptConf->load();
my %o = $option->set( probabilityhour => '0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,4,5,6,30,8,0,0,0', probabilityweek => '0:0,2:10,3:10,3:30,1:50,1:5,0:0' )
    ->get( qw( flowlineid=i version=s probabilityhour=s  probabilityweek=s todate=s deployuuid=s testuuid=s ) )->dump();

$option->assert( 'flowlineid', 'version' );

$o{todate} ||= POSIX::strftime( "%Y-%m-%d", localtime( time - 86400 * 100 ) );

my $db = MYDB->new( "$RealBin/../conf/conn" );

Code->new( 'expand' )->run( db => $db, %o );
